#include "time_test.h"
TIM_HandleTypeDef *used_timer;
int inited = 0;
float time_base = 0;
long int start_time [10]= {0};
long int end_time [10]= {0};
int state[10] = {0};//定义一个定时器的状态，0为空闲，1为计时中
void time_test_init(TIM_HandleTypeDef *timer)
{
    used_timer = timer;
    inited = 1;
    //获取timer的预分频值
}
void start_record(long int cut,int id)
{
    if(id<0 || id>10)
    {
        return;
    }
    start_time[id] = cut;
    state[id] = 1;
}
void end_record(long int cut,int id)
{
    if(id<0 || id>10)
    {
        return;
    }
    end_time[id] = cut;
    state[id] = 0;
}

long int get_record(int id,float time_base)
{
    if(state[id] == 1)
    {
        return -1;
    }
    else
    {
        return (end_time[id] - start_time[id])*time_base;
    }
}



